home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / util / blank / bserver_v14.lha / BServer_v1.4 / Sources.lha / Sources / clients / ShutScreen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-23  |  4.3 KB  |  175 lines

  1. ; /*
  2. sc RESOPT IGNORE=73 DATA=NEAR NMINC UCHAR CONSTLIB STREQ STRMERGE NOSTKCHK NOSTDIO OPTIMIZE OPTSIZE shutscreen.c
  3. slink from lib:c.o shutscreen.o to //Clients/ShutScreen lib /lib/client.lib lib:sc.lib lib:amiga.lib SC SD STRIPDEBUG NOICONS
  4. delete shutscreen.o
  5. quit
  6.  
  7.  ShutScreen 1.2  (Client for BServer)
  8.  
  9.  Copyright © 1994-1995 Stefano Reksten of 3AM - The Three Amigos!!!
  10.  All rights reserved.
  11. */
  12.  
  13. #include <intuition/intuition.h>
  14. #include <intuition/intuitionbase.h>
  15. #include <graphics/scale.h>
  16.  
  17. #include <proto/exec.h>
  18. #include <proto/intuition.h>
  19. #include <proto/graphics.h>
  20.  
  21. #include "/include/client.h"
  22. #include "/include/bitmap/bitmap.h"
  23. #include "/include/bitmap/bitmap_pragmas.h"
  24.  
  25. char *ver = "$VER: ShutScreen 1.2 "__AMIGADATE__;
  26.  
  27. struct IntuitionBase *IntuitionBase;
  28. struct GfxBase *GfxBase;
  29. struct Library *BitMapBase;
  30.  
  31. struct Screen *clonescr, *scr;
  32. UWORD scrwidth, scrheight, scrdepth;
  33. ULONG command;
  34.  
  35. struct BitMap *bmap, *scalebmap;
  36. struct DisplayIDInformation *dinfo;
  37.  
  38. struct BitMapScaleInfo myscaleinfo = {
  39.     NULL, NULL, NULL, 1, 1, 0, 0,
  40.     0, 0, 0, 0, 0, 0, NULL };
  41.  
  42. void Shut( void )
  43. {
  44. BOOL still_blitting;
  45. BOOL blanking, success = FALSE;
  46. UWORD n, frame, top;
  47. ULONG color, darkest_color = 0xF, darkest_index = 0;
  48.  
  49. clonescr = IntuitionBase->FirstScreen;
  50. scrwidth = clonescr->Width;
  51. scrheight = clonescr->Height;
  52. scrdepth = clonescr->RastPort.BitMap->Depth;
  53.  
  54. if ( scalebmap = CreateBitMap( scrwidth, scrheight, scrdepth ) )
  55.     {
  56.     if ( bmap = CreateBitMap( scrwidth, scrheight, scrdepth ) )
  57.         {
  58.         BltBitMap( clonescr->RastPort.BitMap, 0, 0,
  59.             bmap, 0, 0, scrwidth, scrheight, 0xC0, 0xFF, NULL );
  60.  
  61.         myscaleinfo.bsi_SrcBitMap = clonescr->RastPort.BitMap;
  62.         myscaleinfo.bsi_TempBitMap = scalebmap;
  63.         myscaleinfo.bsi_DestBitMap = bmap;
  64.         myscaleinfo.bsi_Width = scrwidth;
  65.         myscaleinfo.bsi_Height = scrheight;
  66.         myscaleinfo.bsi_VertDen = scrheight;
  67.  
  68.         if ( scr = OpenScreenTags( NULL,
  69.             SA_Width, scrwidth,
  70.             SA_Height, scrheight,
  71.             SA_Depth, scrdepth,
  72.             SA_DisplayID, GetVPModeID( &clonescr->ViewPort ),
  73.             SA_BitMap, bmap,
  74.             SA_Overscan, OSCAN_TEXT,
  75.             TAG_END ) )
  76.             {
  77.             if ( scr->ViewPort.ColorMap = GetColorMap( 1<<scrdepth ) )
  78.                 {
  79.                 for ( n = 0; n < 1<<scrdepth; n++ )
  80.                     {
  81.                     color = GetRGB4( clonescr->ViewPort.ColorMap, n );
  82.                     if ( (color & 0xF0)>>4 < darkest_color )
  83.                         {
  84.                         darkest_color = (color & 0xF0)>>4;
  85.                         darkest_index = n;
  86.                         }
  87.                     SetRGB4( &scr->ViewPort, n, color >> 8, (color & 0xF0) >> 4, color & 0xF );
  88.                     }
  89.  
  90.                 ScreenToFront( scr );
  91.  
  92.                 success = TRUE;
  93.                 SpritesOff();
  94.  
  95.                 blanking = TRUE;
  96.                 still_blitting = TRUE;
  97.                 frame = 0;
  98.                 top = 0;
  99.  
  100.                 SetAPen( &scr->RastPort, darkest_index );
  101.  
  102.                 while( blanking )
  103.                     {
  104.                     if ( still_blitting )
  105.                         command = GetServerCommand();
  106.                     else
  107.                         command = WaitServerCommand();
  108.  
  109.                     if ( command != COMMAND_IDLE )
  110.                         blanking = FALSE;
  111.                     else
  112.                     if ( still_blitting )
  113.                         {
  114.                         frame += 2;
  115.                         if ( frame > scrheight )
  116.                             {
  117.                             SetAPen( &scr->RastPort, 0 );
  118.                             SetRGB4( &scr->ViewPort, 0, 0, 0, 0 );
  119.                             SetRast( &scr->RastPort, 0 );
  120.                             still_blitting = FALSE;
  121.                             }
  122.                         else
  123.                             {
  124.                             myscaleinfo.bsi_VertNum = scrheight - frame;
  125.                             myscaleinfo.bsi_DestTopEdge = 1+top>>1;
  126.                             ScaleBitMap( &myscaleinfo );
  127.                             }
  128.  
  129.                         Move( &scr->RastPort, 0, top );
  130.                         Draw( &scr->RastPort, scrwidth - 1, top );
  131.                         Move( &scr->RastPort, 0, scrheight - top - 2);
  132.                         Draw( &scr->RastPort, scrwidth - 1, scrheight - top - 2 );
  133.                         Move( &scr->RastPort, 0, scrheight - top - 1);
  134.                         Draw( &scr->RastPort, scrwidth - 1, scrheight - top - 1 );
  135.                         top++;
  136.  
  137.                         }
  138.                     }
  139.  
  140.                 SpritesOn();
  141.                 FreeColorMap( scr->ViewPort.ColorMap );
  142.                 }
  143.             CloseScreen( scr );
  144.             }
  145.         DisposeBitMap( bmap );
  146.         }
  147.     DisposeBitMap( scalebmap );
  148.     }
  149.  
  150. if ( !success )
  151.     SendClientMsg( ACTION_FAILED );
  152. }
  153.  
  154.  
  155. void __main( char *line )
  156. {
  157. if ( IntuitionBase = (struct IntuitionBase *)OpenLibrary( "intuition.library", 36L ) )
  158.     {
  159.     if ( GfxBase = (struct GfxBase *)OpenLibrary( "graphics.library",0L ) )
  160.         {
  161.         if ( BitMapBase = OpenLibrary( "bitmap.library", 0L ) )
  162.             {
  163.             if ( dinfo = OpenCommunication() )
  164.                 {
  165.                 Shut();
  166.                 CloseCommunication( dinfo );
  167.                 }
  168.             CloseLibrary( BitMapBase );
  169.             }
  170.         CloseLibrary( (struct Library *)GfxBase );
  171.         }
  172.     CloseLibrary( (struct Library *)IntuitionBase );
  173.     }
  174. }
  175.